//
//  UnboundGatewayView.m
//  YSSmartHome
//
//  Created by yanghao on 2016/12/7.
//  Copyright © 2016年 yahaong. All rights reserved.
//

#import "UnboundGatewayView.h"
#import "SearchGatewayButton.h"
#import "YHMarcros.h"

@interface UnboundGatewayView ()

@property (nullable, nonatomic, strong) SearchGatewayButton *mBtnSearch;

@end

@implementation UnboundGatewayView

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        [self setupUI];
    }
    return self;
}

- (void)searchGateway {
    if (self.gatewaySearch)
    {
        self.gatewaySearch();
    }
}
- (void) setupUI
{
    self.backgroundColor =  kBgColor;
    [self addSubview:self.mBtnSearch];
    [self.mBtnSearch mas_makeConstraints:^(MASConstraintMaker *make) {
        make.width.equalTo(kIphoneSize_Widith(300));
        make.centerX.equalTo(self);
        make.top.equalTo(kIphoneSize_Height(50));
        make.height.equalTo(kIphoneSize_Height(220));
    }];
}
#pragma mark - lazy loading

- (SearchGatewayButton *)mBtnSearch
{
    if (!_mBtnSearch) {
        _mBtnSearch = [SearchGatewayButton buttonWithType:UIButtonTypeCustom];
        [_mBtnSearch addTarget:self action:@selector(searchGateway) forControlEvents:UIControlEventTouchUpInside];
        [_mBtnSearch setTitle:@"点击搜索并连接附近网关设备" forState:UIControlStateNormal];
        [_mBtnSearch setImage:[UIImage imageNamed:@"search"] forState:UIControlStateNormal];
    }
    return _mBtnSearch;
}

@end
